import java.util.Scanner;

/**
 * @Title: 前缀和
 * @Author 贾金博
 * @Package PACKAGE_NAME
 * @Date 2024/3/3 20:05
 * @description: 已经忘得一干二净了 寄了
 */
public class 前缀和 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] a = new int[n + 10]; // a[i]表示的是前i项的和
        for(int i = 1; i <= n; ++ i ) {
            a[i] = sc.nextInt();
            a[i] += a[i - 1];
        }

        while(m -- != 0) {
            int l = sc.nextInt();
            int r = sc.nextInt();
          //  System.out.println("l = " + l + " r = " + r);
            System.out.println(a[r] - a[l - 1]);
        }
    }
}
